<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var totalMoney = function (n) {
      let ans = 0, monday = 1;
      for (let i = 1; i <= n; i++) {
        if (i > 1 && (i % 7) === 1) { // 取余判断是周一
          monday = Math.floor(i / 7) + 1; // 取是第几个下周一，重置周一开始存的钱
        }
        ans += monday;
        monday++;
      }
      return ans;
    };
    console.log(totalMoney(4));
  </script>
</body>

</html>